package com.followmeandroid.GCM;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;

/**
 * Created by Adam on 11/29/2014.
 */
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

    /**
     * Receives push notifications, and sends the request to the
     * service layer to be processed.
     * @param context      The given context.
     * @param intent       The given intent.
     */
    @Override
    public void onReceive(Context context, Intent intent) {
        GcmIntentService.setContext(context);

        ComponentName comp = new ComponentName(context.getPackageName(),
                GcmIntentService.class.getName());
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }
}
